<%-- Copyright (c) 2002 BroadVision, Inc. All rights reserved              --%>
<%-- The product described in this manual may be protected by one or more  --%>
<%-- U.S. and International patents. The BroadVision One-To-One software   --%>
<%-- is covered by U.S. patent 5,710,887.                                  --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and the BroadVision logo are registered       --%>
<%-- trademarks, and BroadVision One-To-One is a trademark of BroadVision, --%>
<%-- Inc. IONA and Orbix are trademarks of IONA Technologies, Ltd. RSA,    --%>
<%-- MD5, and RC2 are trademarks of RSA Data Security, Inc. All other      --%>
<%-- trademarks, service marks, and trade names belong to their respective --%>
<%-- owners. BroadVision, Inc. disclaims any proprietary interest in the   --%>
<%-- marks and names of others.                                            --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<%
  String ctxPath = request.getContextPath();
%>



<script language="javascript" >

<%@ include file = "/mc/common/jsutils.jsp" %>

function doDeleteAction(field, theForm) {
    theForm.action = "<html:rewrite page="/em/ruleset/ruleDelete.do"/>";
    theForm.submit();
  }
function doNewAction(theForm){
   theForm.action = "<html:rewrite page="/em/ruleset/ruleNew.do"/>";
   theForm.submit();
      
}

 function confirmSegmentDelete() {
      return confirm("<bean-el:message bundle="em" key="emarketing.ruleset.javaScript.alert.deleteRule"/>");
 }
    
</SCRIPT>

<c:set var="formBean" value="${emRulesListForm}" />
<c:set var="formBeanMap" value="${formBean.map}" />
<c:set var="viewBean" value="${emRulesListView}" />
<c:set var="viewBeanMap" value="${viewBean.map}" />

<c:set var="addImg">
<img src="<%= ctxPath %>/mc/images/action/icon_add.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean:message key="button.add" bundle="em"/>" title="<bean:message key="button.add" bundle="em"/>">
</c:set>
<c:set var="editImg">
<img src="<%= ctxPath %>/mc/images/action/icon_edit.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean:message key="button.edit" bundle="em"/>" title="<bean:message key="button.edit" bundle="em"/>">
</c:set>
<c:set var="deleteImg">
<img src="<%= ctxPath %>/mc/images/action/icon_delete.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean:message key="button.delete" bundle="em"/>" title="<bean:message key="button.delete" bundle="em"/>">
</c:set>
<c:set var="moveUpImg">
<img src="<%= ctxPath %>/mc/images/action/icon_moveup.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean:message key="button.moveup" bundle="em"/>" title="<bean:message key="button.moveup" bundle="em"/>">
</c:set>
<c:set var="moveDownImg">
<img src="<%= ctxPath %>/mc/images/action/icon_movedown.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean:message key="button.movedown" bundle="em"/>" title="<bean:message key="button.movedown" bundle="em"/>">
</c:set>


<html-el:form action="/em/ruleset/rulesList.do">
<html-el:hidden property="ruleSetOid"  value="${param.ruleSetOid}" />

<table width="100%" border="0" cellspacing="0" cellpadding="0"
	class="zoneFive">
		<td valign="top" width="100%">
		<div class="pageTitle">
      	 	<bean-el:message bundle="em" key="emarketing.ruleSet.rulesList.pageTitle" arg0="${viewBeanMap.ruleSetName}"/>    		
		</div>


		<div class="errorMessage"><html:errors/></div>
		<jsp:include page="/mc/common/pagetab.jsp" flush="true" /> 
		<div class="pageSubtitle">
			<span class="left">
			  <bean:size id="rulesListSize" name="viewBean" property="rulesList" />
			  <bean-el:message bundle="em" key="emarketing.ruleSet.rulesList.subTitle" arg0="${rulesListSize}"/>             
			</span>
			<span class="right">
			<c:choose>
			    <c:when test='${viewBeanMap.createType}'>
			         <input type="button"  name="Create" class="globalButton"
			                              value="<bean:message bundle="em" key="emarketing.ruleset.ruleSetView.button.newRule"/>" 
			                              onClick="doNewAction(this.form);">
			     </c:when>
			     <c:otherwise>                        
			     </c:otherwise>
             		</c:choose>
			</span>
	    </div>

	<c:if test="${!empty viewBeanMap.rulesList}">
	    <div class="globalButtonWrap">
	        <c:choose>
                   <c:when test='${viewBeanMap.deleteAllType}'>
		              <input type="button"  name="selectAllRules" class="globalButton" 
                              value="<bean:message bundle="em" key="button.selectAll"/>" 
                              onClick="check(this.form.selectedIds, this);">
          
                      <input type="button" name="actionDelete" class="globalButton" 
             				 onclick="if (isAnyChecked(this.form.selectedIds, 
             				 '<bean:message bundle="em" key="emarketing.ruleset.rulesList.deleteAlert" />', 
             				 '<bean:message bundle="em" key="emarketing.ruleset.rulesList.confirmDelete" />')) 
             				 doDeleteAction(this.form.selectedIds, this.form);"
                              value="<bean:message bundle="em" key="button.delete"/>"  > 
                   </c:when>
             </c:choose>
   		      		
         </div>
       </c:if>
          
		  <!-- Start List here -->
          <table class="dataTable" width="100%" border="0" cellspacing="1" cellpadding="2">
            <tr class="listHeader"> 
              <th id="Checkboxes" width="3%">&nbsp;</th>
              <th valign="top" id="RuleSetName" align="left">
                <bean:message bundle="em" key="emarketing.ruleset.rulesList.ruleName"/>
              </th>
              <th valign="top" id="Description" align="left">
                <bean:message bundle="em" key="emarketing.ruleset.rulesList.description"/>
              </th>
              <th valign="top" id="Actions" align="left" width="15%" wrap>
                <bean:message bundle="em" key="emarketing.ruleset.text.action"/>
              </th>
            </tr>
                    
            <!-- results -->
          <c:if test="${empty viewBeanMap.rulesList}">
            <tr class="listEven">
             <td colspan="6" align="center">
              <bean-el:message key="emarketing.ruleset.rulesList.browse.no.rule" bundle="em" />
             </td>
            </tr>
          </c:if>
                        
            <!--  the rules content -->
            <c:forEach var="item" items="${viewBeanMap.rulesList}" varStatus="index">
          	<c:choose>
            	<c:when test="${(index.count + 1) % 2 == 0}">
              		<tr class="listEven">
            	</c:when>
            	<c:otherwise>
              		<tr class="listOdd">
            	</c:otherwise>
          	</c:choose>
          	
            <td headers="Checkboxes" align="center">
            <input type="checkbox" name="selectedIds" 
          	  onClick="update(this.form.selectedIds, this.form.selectAllRules);"
              value="<c:out value="${item.map.parameters.ruleOid}"/>">
            </td>
             
            <c:url var="viewUrl" value="/em/ruleset/ruleView.do">
             <c:param name="ruleSetOid" value="${item.map.parameters.ruleSetOid}"/>
             <c:param name="ruleOid" value="${item.map.parameters.ruleOid}"/>    
	    	</c:url>
	    	<!--  if viewType is true, show view link, otherwise, donot show -->  
              
                <c:choose>
                   <c:when test='${item.map.viewType}'>
                      <td headers="Name"><a href="<c:out value="${viewUrl}"/>"><c:out value="${item.map.name}"/></a></td>   
                   </c:when>
                   <c:otherwise>   
                      <td headers="Name"><c:out value="${item.map.name}"/></td>                          
                   </c:otherwise>
               </c:choose>
	    	            
            <td headers="Description"><c:out value="${item.map.description}"/></td>
            <td headers="Actions">
            	<html:link name="item" property="parameters" page="/em/ruleset/ruleMove.do?up=1">
                     <c:out value='${moveUpImg}' escapeXml="false"/>
                </html:link>
 
            	<html:link name="item" property="parameters" page="/em/ruleset/ruleMove.do?up=0">
                     <c:out value='${moveDownImg}' escapeXml="false"/>
                </html:link>
              
               <!--  if editType is true, show edit icon, otherwise, donot show -->  
                <c:choose>
                   <c:when test='${item.map.editType}'>
                         <html:link name="item" property="parameters" page="/em/ruleset/ruleEdit.do">
                           <c:out value='${editImg}' escapeXml="false"/>
                         </html:link>
                   </c:when>
                   <c:otherwise>                          
                   </c:otherwise>
               </c:choose>
            	   	
            <!--  if deleteType is true, show delete icon, otherwise, donot show -->	   	
               <c:choose>
                   <c:when test='${item.map.deleteType}'>
                      <html:link name="item" property="parameters" page="/em/ruleset/ruleDelete.do"
                           onclick="return confirmSegmentDelete();">
                           <c:out value='${deleteImg}' escapeXml="false"/>
                      </html:link>                  
                   </c:when>
                   <c:otherwise>                          
                   </c:otherwise>
               </c:choose>	   	
            	   	        	
            </td>
            </c:forEach>             
          </tr>	
    </table> 
    <c:if test="${not empty viewBeanMap.rulesList}">
    	<%@ include file="/mc/common/pager.jsp" %>
    </c:if>
    </td>
  </tr>
</table>

</html-el:form>

